home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / bash / bash_110 / mint / bash110s.zoo / bash-1.10 / support / mktarfile < prev   
Encoding:
Text File  |  1991-07-07  |  924 b   |  49 lines

  1. #!./bash
  2. # How to make a distribution tarfile.
  3. #
  4. # $1 is the name of the program.
  5. # $2 is the version number.
  6. # Remaining args are files to tar.
  7.  
  8. PROGRAM=$1
  9. VERSION=$2
  10.  
  11. shift; shift
  12.  
  13. if [ "$PROGRAM" = "" -o "$VERSION" = "" ]; then
  14.   echo "Usage: make-tarfile <progname> <version> <file ...>"
  15.   exit 2;
  16. fi
  17.  
  18. TARFILE=$PROGRAM.tar
  19. TARDIR=$PROGRAM-$VERSION
  20.  
  21. rm -rf $TARFILE $TARDIR
  22. mkdir $TARDIR
  23. topdir=$(pwd)
  24. where_I_am=$TARDIR
  25.  
  26. trap "cd $topdir" 3
  27.  
  28. for i in $*; do
  29.   filename=$i
  30.   while [ "$filename" ]; do
  31.     remainder=$(echo ${filename#*/})
  32.     dir=$(echo $filename | sed "s@$remainder@@" | sed "s@/@@")
  33.     if [ "$dir" ]; then
  34.        if [ ! -d $where_I_am/$dir ]; then mkdir $where_I_am/$dir; fi
  35.        cd $where_I_am/$dir; where_I_am=$(pwd)
  36.        filename=$remainder
  37.     else
  38.        break
  39.     fi
  40.   done
  41.   cd $topdir; where_I_am=$TARDIR
  42.   ln -s $topdir/$i $TARDIR/$i
  43. done
  44.  
  45. tar -chf $TARFILE $TARDIR
  46. rm -rf $TARDIR
  47.  
  48. exit 0
  49.